﻿using UnityEditor;
using UnityEditor.UI;
using UnityEngine;

namespace BToolkit
{
    [CustomEditor(typeof(PolygonImage))]
    public class PolygonImageEditor : ImageEditor
    {
        PolygonImage circleImage;
        SerializedProperty points;

        protected override void OnEnable()
        {
            base.OnEnable();

            circleImage = (PolygonImage)target;

            points = serializedObject.FindProperty("points");

        }

        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUILayout.PropertyField(points);

            EditorGUILayout.Space();

            circleImage.texScale = EditorGUILayout.FloatField("Tex Scale", circleImage.texScale);
            if (circleImage.texScale < 0) circleImage.texScale = 0;

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(target);
                circleImage.SetAllDirty();
            }
        }
    }
}